﻿using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace Ultima.Xna
{
    public class ApplicationInfo
    {
        private Assembly _assembly;

        /// <summary>
        /// Gets the assembly used to create the ApplicationInfo
        /// </summary>
        public Assembly Assembly
        {
            get { return _assembly; }
        }

        /// <summary>
        /// Gets the current running Process
        /// </summary>
        public Process Process
        {
            get { return Process.GetCurrentProcess(); }
        }

        /// <summary>
        /// Gets the version of the Application Assembly
        /// </summary>
        public Version Version
        {
            get { return _assembly.GetName().Version; }
        }

        /// <summary>
        /// Gets the base directory of the Application
        /// </summary>
        public string BaseDirectory
        {
            get { return Path.GetDirectoryName(ExePath); }
        }

        /// <summary>
        /// Gets the exe path to Application
        /// </summary>
        public string ExePath
        {
            get { return _assembly.Location; }
        }

        /// <summary>
        /// Gets a boolean value indicating wether we are in 64bit mode or not.
        /// </summary>
        public bool Is64Bit
        {
            get { return IntPtr.Size == 8; }
        }

        /// <summary>
        /// Creates a new instance of the ApplicationInfo object, the default Assembly used will be Assembly.GetEntryAssembly();
        /// </summary>
        public ApplicationInfo()
        {
            _assembly = System.Reflection.Assembly.GetEntryAssembly();
        }

        /// <summary>
        /// Creates a new instance of ApplicationInfo.
        /// </summary>
        public ApplicationInfo(Assembly assembly)
        {
            _assembly = assembly;
        }
    }
}
